import 'package:animal/constant/color.dart';
import 'package:animal/constant/font.dart';
import 'package:animal/ui/login/controller/short_login_controller.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/code/code_input_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

///短信登录
class ShortLoginPage extends StatelessWidget {
  const ShortLoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(ShortLoginController());
    return Scaffold(
      backgroundColor: Colors.white,
      resizeToAvoidBottomInset: false,
      body: SingleChildScrollView(
        child: Container(
          margin: EdgeInsets.only(left: ScreenUtil().L(30), right: ScreenUtil().L(30), top: ScreenUtil().L(30), bottom: ScreenUtil().L(10)),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                children: [
                  Row(
                    children: [
                      Text("使用短信登录", style: KFontConstant.myTextStyle(size: 20, bold: true, color: Colors.black)),
                    ],
                  ),
                  Container(height: ScreenUtil().L(10)),
                  Container(
                    decoration: BoxDecoration(border: Border(bottom: BorderSide(color: const Color(0XFFDEE0E0), width: ScreenUtil().L(0.5)))),
                    child: TextField(
                      controller: controller.controller,
                      inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'[0-9]'))],
                      focusNode: controller.userFocusNode,
                      decoration: InputDecoration(
                        hintText: "请输入手机号码",
                        hintStyle: KFontConstant.myTextStyle(size: 15, color: KColorConstant.black999999),
                        border: InputBorder.none,
                      ),
                    ),
                  ),
                  Container(height: ScreenUtil().L(10)),
                  CodeInputPage(
                    textEditingController: controller.codeController,
                    phoneEditingController: controller.controller,
                    tag: "shortLogin",
                    btnColor: KColorConstant.btnColor19ACE5,
                    decoration: BoxDecoration(border: Border(bottom: BorderSide(color: const Color(0XFFDEE0E0), width: ScreenUtil().L(0.5)))),
                  ),
                  Container(height: ScreenUtil().L(70)),
                  CupertinoButton(
                    onPressed: () => controller.codeLogin(),
                    color: KColorConstant.btnColorF8633B,
                    borderRadius: BorderRadius.circular(ScreenUtil().L(5)),
                    padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(130)),
                    child: Text(
                      "登录",
                      style: KFontConstant.myTextStyle(size: 17, color: Colors.white),
                    ),
                  ),
                  Container(height: ScreenUtil().L(15.5)),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Obx(
                        () => GFCheckbox(
                          size: ScreenUtil().L(16),
                          activeBgColor: GFColors.SUCCESS,
                          inactiveBorderColor: KColorConstant.black999999,
                          type: GFCheckboxType.circle,
                          activeIcon: Image.asset("icons/icon_check_blue_two.png"),
                          onChanged: (value) {
                            controller.checkTap();
                          },
                          value: controller.checkBtn.value,
                        ),
                      ),
                      Container(
                        width: ScreenUtil().L(4),
                      ),
                      Text("已阅读并同意", style: KFontConstant.myTextStyle(size: 12, color: KColorConstant.black999999)),
                      InkWell(
                          child: Text("《用户服务协议》", style: KFontConstant.myTextStyle(size: 12, color: KColorConstant.blue3C5A99)),
                          onTap: () => controller.gotoUserAgreement()),
                      Text("和", style: KFontConstant.myTextStyle(size: 12, color: KColorConstant.black999999)),
                      InkWell(
                          child: Text("《隐私政策》", style: KFontConstant.myTextStyle(size: 12, color: KColorConstant.blue3C5A99)),
                          onTap: () => controller.gotoPrivacy()),
                    ],
                  ),
                  Container(height: ScreenUtil().L(15)),
                  Text("未注册用户登录时默认注册新账号", style: KFontConstant.myTextStyle(size: 13, color: KColorConstant.black666666)),
                  Container(height: ScreenUtil().L(130)),
                  GFButton(
                      onPressed: () => controller.gotoForgetPwd(),
                      fullWidthButton: true,
                      type: GFButtonType.transparent,
                      size: GFSize.LARGE,
                      child: Text("本机号码一键登录", style: KFontConstant.myTextStyle(size: 15, color: Colors.blue, bold: true))),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
